# 初始化
import os

import django

from dvadmin.utils.core_initialize import CoreInitialize

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'application.settings')
django.setup()

from dvadmin.system.models import Dept, Role, Users, DeviceTypes, SysTypes, SysDict, Menu, Structures, RoadsInfos


# from dvadmin.system.util import init_area


class Initialize(CoreInitialize):
    creator_id = 1

    def init_dept(self):
        """
        初始化部门信息
        """
        self.dept_data = [
            {"id": 1, "name": "遵义分中心", "sort": 1, "parent_id": None},
            {"id": 2, "name": "财务部", "sort": 2,
             "parent_id": 1},
            {"id": 3, "name": "机电科", "sort": 2,
             "parent_id": 1}
        ]
        self.save(Dept, self.dept_data, "部门信息")

    # def init_button(self):
    #     """
    #     初始化权限表标识
    #     """
    #     self.button_data = [
    #         {"id": "4547b93a-36b9-410d-987c-3c52a9b51156", "name": "编辑", "value": "Update", },
    #         {"id": "4a410769-6b0a-4ed3-90f0-b5d89a6f802c", "name": "删除", "value": "Delete", },
    #         {"id": "644e9c34-e3d6-4518-b795-a603a6e9a137", "name": "单例", "value": "Retrieve", },
    #         {"id": "80cb145b-5035-4517-a28a-7d59426f73f8", "name": "新增", "value": "Create", },
    #         {"id": "ccc3f35f-c80c-4929-b8cc-67531698f397", "name": "查询", "value": "Search", },
    #         {"id": "83a9b774-4669-4d2f-b61d-8ee4944c2316", "name": "保存", "value": "Save", },
    #     ]
    #     self.save(Button, self.button_data, "权限表标识")

    # def init_menu(self):
    #     """
    #     初始化菜单表
    #     """
    #     self.menu_data = [
    #         {"id": "151035da-77a3-4a62-b474-fce6824571fb", "name": "按钮管理", "sort": 6, "web_path": "/button",
    #          "icon": "support", "parent_id": "54f769b0-3dff-416c-8102-e55ec44827cc", "component": "system/button",
    #          "component_name": "buttons", "visible": 0},
    #         {"id": "15c9ebc5-d12f-470a-a560-938a7dc57570", "name": "角色管理", "sort": 3, "web_path": "/role",
    #          "icon": "users", "parent_id": "54f769b0-3dff-416c-8102-e55ec44827cc", "component": "system/role",
    #          "component_name": "role"},
    #         {"id": "4236eb70-1558-43a0-9cf2-037230c547f9", "name": "部门管理", "sort": 1, "web_path": "/dept",
    #          "icon": "university", "parent_id": "54f769b0-3dff-416c-8102-e55ec44827cc", "component": "system/dept",
    #          "component_name": "dept"},
    #         {"id": "4ba07859-8b73-4524-a1a6-bbff36d98337", "name": "操作日志", "sort": 1, "web_path": "/operationLog",
    #          "icon": "gears", "parent_id": "c236fb6b-ddaa-4deb-b79b-16e42d9f347f",
    #          "component": "system/log/operationLog", "component_name": "operationLog"},
    #         {"id": "54f769b0-3dff-416c-8102-e55ec44827cc", "name": "系统管理", "sort": 1, "web_path": "",
    #          "icon": "briefcase", "parent_id": None, },
    #         {"id": "56c3f341-4f46-4b04-9cfc-c8a14701707e", "name": "菜单管理", "sort": 2, "web_path": "/menu",
    #          "icon": "reorder", "parent_id": "54f769b0-3dff-416c-8102-e55ec44827cc", "component": "system/menu",
    #          "component_name": "menu"},
    #         {"id": "e0f53902-e901-490c-83f3-331e60b97fcf", "name": "菜单按钮", "sort": 2, "web_path": "/menuButton/:id",
    #          "icon": "clock-o", "parent_id": "54f769b0-3dff-416c-8102-e55ec44827cc", "component": "system/menuButton",
    #          "visible": 0},
    #         {"id": "5a05450c-cec2-4819-8d54-e0d6f6aac3a6", "name": "用户管理", "sort": 5, "web_path": "/user",
    #          "icon": "user", "parent_id": "54f769b0-3dff-416c-8102-e55ec44827cc", "component": "system/user",
    #          "component_name": "user"},
    #         {"id": "a607e820-36e5-45c0-aabf-85a8e4e2c7ac", "name": "权限管理", "sort": 4, "web_path": "/rolePermission",
    #          "icon": "user-plus", "parent_id": "54f769b0-3dff-416c-8102-e55ec44827cc",
    #          "component": "system/rolePermission", "component_name": "rolePermission"},
    #         {"id": "c236fb6b-ddaa-4deb-b79b-16e42d9f347f", "name": "日志管理", "sort": 2, "web_path": "", "icon": "clock-o",
    #          "parent_id": None},
    #         {"id": "97b8fd88-0510-4db7-8d53-983a04843c4c", "name": "字典管理", "sort": 1, "web_path": "/dictionary",
    #          "icon": "clock-o", "parent_id": "54f769b0-3dff-416c-8102-e55ec44827cc", "component": "system/dictionary",
    #          "component_name": "dictionary"},
    #         {"id": "97b8fd88-0510-4db7-8d53-983a04844c4c", "name": "地区管理", "sort": 6, "web_path": "/areas",
    #          "icon": "area-chart", "parent_id": "54f769b0-3dff-416c-8102-e55ec44827cc", "component": "system/areas",
    #          "component_name": "areas"},
    #         {"id": "805390f3-a6e6-411e-9798-eebd34b76204", "name": "附件管理", "sort": 7, "web_path": "",
    #          "icon": "envelope", "parent_id": "54f769b0-3dff-416c-8102-e55ec44827cc", },
    #         {"id": "ac956a17-87d3-4b61-8f72-44a97b9fbcd1", "name": "图片管理", "sort": 1, "web_path": "/img",
    #          "icon": "file-image-o", "parent_id": "805390f3-a6e6-411e-9798-eebd34b76204",
    #          "component": "system/fileList/img/index",
    #          "component_name": "imgs"},
    #         {"id": "28723f68-e470-493a-bbe7-7b759fe26674", "name": "文件管理", "sort": 2, "web_path": "/file",
    #          "icon": "file-excel-o", "parent_id": "805390f3-a6e6-411e-9798-eebd34b76204",
    #          "component": "system/fileList/file/index",
    #          "component_name": "file"},
    #     ]
    #     self.save(Menu, self.menu_data, "菜单表")

    # def init_menu_button(self):
    #     """
    #     初始化菜单权限表
    #     """
    #     self.menu_button_data = [
    #         {"id": "0209de89-6b9f-4d8a-84d3-ccfc3cc8b4da", "menu_id": "151035da-77a3-4a62-b474-fce6824571fb",
    #          "name": "编辑", "value": "Update", "api": "/api/system/button/{id}/", "method": 2},
    #         {"id": "04896a47-0f3a-4e2f-a111-bfe15f9e31c5", "menu_id": "56c3f341-4f46-4b04-9cfc-c8a14701707e",
    #          "name": "编辑", "value": "Update", "api": "/api/system/menu/{id}/", "method": 2},
    #         {"id": "10610c56-cec2-4774-9468-e1c763e59e70", "menu_id": "4236eb70-1558-43a0-9cf2-037230c547f9",
    #          "name": "新增", "value": "Create", "api": "/api/system/dept/", "method": 1},
    #         {"id": "140166e2-471e-455e-9dcd-05cebbbab95d", "menu_id": "15c9ebc5-d12f-470a-a560-938a7dc57570",
    #          "name": "查询", "value": "Search", "api": "/api/system/role/", "method": 0},
    #         {"id": "14e7088f-a39b-47ae-bd67-b9bbcabae96b", "menu_id": "5a05450c-cec2-4819-8d54-e0d6f6aac3a6",
    #          "name": "单例", "value": "Retrieve", "api": "/api/system/user/{id}/", "method": 0},
    #         {"id": "1b4f27a7-8ab8-4388-ae57-46e29976cf0e", "menu_id": "151035da-77a3-4a62-b474-fce6824571fb",
    #          "name": "新增", "value": "Create", "api": "/api/system/button/", "method": 1},
    #         {"id": "2a3d4756-4d51-4129-b3c4-b2c7a00dbb8a", "menu_id": "15c9ebc5-d12f-470a-a560-938a7dc57570",
    #          "name": "新增", "value": "Create", "api": "/api/system/role/", "method": 1},
    #         {"id": "37462e31-3cdf-4576-af10-5958f53b1bef", "menu_id": "4ba07859-8b73-4524-a1a6-bbff36d98337",
    #          "name": "查询", "value": "Search", "api": "/api/system/operation_log/", "method": 0},
    #         {"id": "3e11db64-b8e8-4558-963b-71d063a7db16", "menu_id": "4236eb70-1558-43a0-9cf2-037230c547f9",
    #          "name": "编辑", "value": "Update", "api": "/api/system/dept/{id}/", "method": 2},
    #         {"id": "3fd6ae6c-fd76-4465-b2b6-db672f4bd79e", "menu_id": "15c9ebc5-d12f-470a-a560-938a7dc57570",
    #          "name": "删除", "value": "Delete", "api": "/api/system/role/{id}/", "method": 3},
    #         {"id": "42ad6e05-7c84-444f-bcae-09de84f4988b", "menu_id": "56c3f341-4f46-4b04-9cfc-c8a14701707e",
    #          "name": "查询", "value": "Search", "api": "/api/system/menu/", "method": 0},
    #         {"id": "43696212-ecba-4e66-8678-33c9bc935c76", "menu_id": "5a05450c-cec2-4819-8d54-e0d6f6aac3a6",
    #          "name": "查询", "value": "Search", "api": "/api/system/user/", "method": 0},
    #         {"id": "51085c21-2279-490f-8878-594f059f7616", "menu_id": "151035da-77a3-4a62-b474-fce6824571fb",
    #          "name": "删除", "value": "Delete", "api": "/api/system/button/{id}/", "method": 3},
    #         {"id": "6208f412-6bca-4d7b-a5a0-0103b7ba6091", "menu_id": "151035da-77a3-4a62-b474-fce6824571fb",
    #          "name": "单例", "value": "Retrieve", "api": "/api/system/button/{id}/", "method": 0},
    #         {"id": "6300774a-d19c-43ad-8102-d7bf341eff33", "menu_id": "4236eb70-1558-43a0-9cf2-037230c547f9",
    #          "name": "单例", "value": "Retrieve", "api": "/api/system/dept/{id}/", "method": 0},
    #         {"id": "646e9790-24f5-4606-abc4-0b5eede12f66", "menu_id": "4236eb70-1558-43a0-9cf2-037230c547f9",
    #          "name": "查询", "value": "Search", "api": "/api/system/dept/", "method": 0},
    #         {"id": "875bdfeb-0c34-441d-8ee3-bb93c21e17dd", "menu_id": "5a05450c-cec2-4819-8d54-e0d6f6aac3a6",
    #          "name": "编辑", "value": "Update", "api": "/api/system/user/{id}/", "method": 2},
    #         {"id": "8ae924bd-576c-4ae1-92eb-b0a98148baae", "menu_id": "56c3f341-4f46-4b04-9cfc-c8a14701707e",
    #          "name": "删除", "value": "Delete", "api": "/api/system/menu/{id}/", "method": 3},
    #         {"id": "8b7a0e79-a6ef-4946-87c6-8c042b887e1c", "menu_id": "4ba07859-8b73-4524-a1a6-bbff36d98337",
    #          "name": "单例", "value": "Retrieve", "api": "/api/system/operation_log/{id}/", "method": 0},
    #         {"id": "96022ae5-6425-47b9-8f89-01edc33eb2b7", "menu_id": "15c9ebc5-d12f-470a-a560-938a7dc57570",
    #          "name": "单例", "value": "Retrieve", "api": "/api/system/role/{id}/", "method": 0},
    #         {"id": "9fc8436a-1996-478f-a155-5de7939a54dc", "menu_id": "5a05450c-cec2-4819-8d54-e0d6f6aac3a6",
    #          "name": "新增", "value": "Create", "api": "/api/system/user/", "method": 1},
    #         {"id": "abe5c07f-0cab-4053-ac24-e782792e9d7f", "menu_id": "56c3f341-4f46-4b04-9cfc-c8a14701707e",
    #          "name": "新增", "value": "Create", "api": "/api/system/menu/", "method": 1},
    #         {"id": "acfde861-1872-47e2-a1f1-abeda5175b7f", "menu_id": "4ba07859-8b73-4524-a1a6-bbff36d98337",
    #          "name": "删除", "value": "Delete", "api": "/api/system/operation_log/{id}/", "method": 3},
    #         {"id": "af60d628-73b1-4c5d-b34e-7c70ab9bd87e", "menu_id": "151035da-77a3-4a62-b474-fce6824571fb",
    #          "name": "查询", "value": "Search", "api": "/api/system/button/", "method": 0},
    #         {"id": "b10f7d08-2592-4b54-8557-b5ca864a029a", "menu_id": "4236eb70-1558-43a0-9cf2-037230c547f9",
    #          "name": "删除", "value": "Delete", "api": "/api/system/dept/{id}/", "method": 3},
    #         {"id": "bb7de9ee-5fd1-46f5-9849-088c522f49c7", "menu_id": "5a05450c-cec2-4819-8d54-e0d6f6aac3a6",
    #          "name": "删除", "value": "Delete", "api": "/api/system/user/{id}/", "method": 3},
    #         {"id": "d22c0176-96e0-48b3-b81e-13443f306af5", "menu_id": "15c9ebc5-d12f-470a-a560-938a7dc57570",
    #          "name": "编辑", "value": "Update", "api": "/api/system/role/{id}/", "method": 2},
    #         {"id": "fcbe4cec-cc2d-436d-92ba-023f8c9ad31c", "menu_id": "56c3f341-4f46-4b04-9cfc-c8a14701707e",
    #          "name": "单例", "value": "Retrieve", "api": "/api/system/menu/{id}/", "method": 0},
    #         {"id": "1a0c96cf-09a6-43b4-b08a-0c5b6e2f7bb8", "menu_id": "a607e820-36e5-45c0-aabf-85a8e4e2c7ac",
    #          "name": "保存", "value": "Retrieve", "api": "/api/system/role/{id}/", "method": 2},
    #         {"id": "bc6104a0-f487-4dfd-a368-fb587d6d57d8", "menu_id": "e0f53902-e901-490c-83f3-331e60b97fcf",
    #          "name": "编辑", "value": "Update", "api": "/api/system/menu_button/{id}/", "method": 2},
    #         {"id": "5aac29b0-5a32-45fb-81c5-437b48f4a5df", "menu_id": "e0f53902-e901-490c-83f3-331e60b97fcf",
    #          "name": "查询", "value": "Search", "api": "/api/system/menu_button/", "method": 0},
    #         {"id": "fc71b446-fde1-439f-ab41-c38f30230caa", "menu_id": "e0f53902-e901-490c-83f3-331e60b97fcf",
    #          "name": "新增", "value": "Create", "api": "/api/system/menu_button/", "method": 1},
    #         {"id": "fe96f32c-6124-4b24-b809-4964186f5163", "menu_id": "e0f53902-e901-490c-83f3-331e60b97fcf",
    #          "name": "单例", "value": "Retrieve", "api": "/api/system/menu_button/{id}/", "method": 0},
    #         {"id": "4fe4b7f5-0bc8-4375-9f39-747e06ec285a", "menu_id": "e0f53902-e901-490c-83f3-331e60b97fcf",
    #          "name": "删除", "value": "Delete", "api": "/api/system/menu_button/{id}/", "method": 3},
    #         {"id": "a599a1a5-ef14-4fdc-9dcc-cb1b1163d6ba", "menu_id": "97b8fd88-0510-4db7-8d53-983a04843c4c",
    #          "name": "编辑", "value": "Update", "api": "/api/system/dictionary/{id}/", "method": 2},
    #         {"id": "7abcbccf-9145-4635-9e33-c825e05c4b9a", "menu_id": "97b8fd88-0510-4db7-8d53-983a04843c4c",
    #          "name": "查询", "value": "Search", "api": "/api/system/dictionary/", "method": 0},
    #         {"id": "57b99dd5-b5af-4789-92b6-7630b606f858", "menu_id": "97b8fd88-0510-4db7-8d53-983a04843c4c",
    #          "name": "新增", "value": "Create", "api": "/api/system/dictionary/", "method": 1},
    #         {"id": "4b81a1cc-917c-46e8-b063-6880814ef02c", "menu_id": "97b8fd88-0510-4db7-8d53-983a04843c4c",
    #          "name": "单例", "value": "Retrieve", "api": "/api/system/dictionary/{id}/", "method": 0},
    #         {"id": "dcfb48c5-a168-4306-acd5-f1277337a504", "menu_id": "97b8fd88-0510-4db7-8d53-983a04843c4c",
    #          "name": "删除", "value": "Delete", "api": "/api/system/dictionary/{id}/", "method": 3},
    #         {"id": "6fecacf0-39af-4838-afcc-20af8dad6f97", "menu_id": "ac956a17-87d3-4b61-8f72-44a97b9fbcd1",
    #          "name": "编辑", "value": "Update", "api": "/api/system/file/{id}/", "method": 2},
    #         {"id": "6fecacf0-39af-4838-afcc-20af8dad6f98", "menu_id": "ac956a17-87d3-4b61-8f72-44a97b9fbcd1",
    #          "name": "查询", "value": "Search", "api": "/api/system/file/", "method": 0},
    #         {"id": "6fecacf0-39af-4838-afcc-20af8dad6f99", "menu_id": "ac956a17-87d3-4b61-8f72-44a97b9fbcd1",
    #          "name": "新增", "value": "Create", "api": "/api/system/file/", "method": 1},
    #         {"id": "6fecacf0-39af-4838-afcc-20af8dad6f9a", "menu_id": "ac956a17-87d3-4b61-8f72-44a97b9fbcd1",
    #          "name": "单例", "value": "Retrieve", "api": "/api/system/file/{id}/", "method": 0},
    #         {"id": "6fecacf0-39af-4838-afcc-20af8dad6f9b", "menu_id": "ac956a17-87d3-4b61-8f72-44a97b9fbcd1",
    #          "name": "删除", "value": "Delete", "api": "/api/system/file/{id}/", "method": 3},
    #         {"id": "0e4e34d0-02bb-40f4-a9fd-621490ccb041", "menu_id": "28723f68-e470-493a-bbe7-7b759fe26674",
    #          "name": "编辑", "value": "Update", "api": "/api/system/img/{id}/", "method": 2},
    #         {"id": "0e4e34d0-02bb-40f4-a9fd-621490ccb042", "menu_id": "28723f68-e470-493a-bbe7-7b759fe26674",
    #          "name": "查询", "value": "Search", "api": "/api/system/img/", "method": 0},
    #         {"id": "0e4e34d0-02bb-40f4-a9fd-621490ccb043", "menu_id": "28723f68-e470-493a-bbe7-7b759fe26674",
    #          "name": "新增", "value": "Create", "api": "/api/system/img/", "method": 1},
    #         {"id": "0e4e34d0-02bb-40f4-a9fd-621490ccb044", "menu_id": "28723f68-e470-493a-bbe7-7b759fe26674",
    #          "name": "单例", "value": "Retrieve", "api": "/api/system/img/{id}/", "method": 0},
    #         {"id": "0e4e34d0-02bb-40f4-a9fd-621490ccb045", "menu_id": "28723f68-e470-493a-bbe7-7b759fe26674",
    #          "name": "删除", "value": "Delete", "api": "/api/system/img/{id}/", "method": 3},
    #         {"id": "0e4e34d0-03bb-40f4-a9fd-621490ccb041", "menu_id": "97b8fd88-0510-4db7-8d53-983a04844c4c",
    #          "name": "编辑", "value": "Update", "api": "/api/system/areas/{id}/", "method": 2},
    #         {"id": "0e4e34d0-04bb-40f4-a9fd-621490ccb042", "menu_id": "97b8fd88-0510-4db7-8d53-983a04844c4c",
    #          "name": "查询", "value": "Search", "api": "/api/system/areas/", "method": 0},
    #         {"id": "0e4e34d0-05bb-40f4-a9fd-621490ccb043", "menu_id": "97b8fd88-0510-4db7-8d53-983a04844c4c",
    #          "name": "新增", "value": "Create", "api": "/api/system/areas/", "method": 1},
    #         {"id": "0e4e34d0-06bb-40f4-a9fd-621490ccb044", "menu_id": "97b8fd88-0510-4db7-8d53-983a04844c4c",
    #          "name": "单例", "value": "Retrieve", "api": "/api/system/areas/{id}/", "method": 0},
    #         {"id": "0e4e34d0-07bb-40f4-a9fd-621490ccb045", "menu_id": "97b8fd88-0510-4db7-8d53-983a04844c4c",
    #          "name": "删除", "value": "Delete", "api": "/api/system/areas/{id}/", "method": 3},
    #     ]
    #     self.save(MenuButton, self.menu_button_data, "菜单权限表")

    def init_role(self):
        """
        初始化角色表
        """
        data = [
            {"id": 1, "name": "管理员", "key": "admin", "sort": 1, "status": 1,
             "admin": 1, "data_range": 3
             },
            {"id": 2, "name": "普通用户", "key": "public", "sort": 2, "status": 1,
             "admin": 0, "data_range": 4
             },

        ]
        self.save(Role, data, "角色表")

    def init_users(self):
        """
        初始化用户表
        """
        data = [
            {"id": 4,
             "password": "pbkdf2_sha256$260000$5Xh9mORDV6upURnvXDDoJi$uE4VFGC2EVbdLI2uClv+bSZDHocx+BE2CQKi0xf/r20=",
             "is_superuser": 0, "is_staff": 0,
             "is_active": 1, "username": "test", "name": "测试",
             "role": [1],
             "dept_id": 3,
             },
            {"id": 1,
             "password": "pbkdf2_sha256$260000$skG9mwWamjqG92zCwbRgcU$lsZsafdmn4/UN2yEghtTAQZjpBVUFGlI9NnDFOWmQuE=",
             "is_superuser": 1, "is_staff": 1,
             "is_active": 1, "username": "superadmin", "name": "超级管理员",
             "dept_id": 1,
             },
            {"id": 3,
             "password": "pbkdf2_sha256$260000$Vmb2g3pXfzcXm7lsn9w7Wl$0Ek75CAVtiqUNGUebYoKtpzmTeCB+f7E1M8V/XtGHiw=",
             "is_superuser": 0, "is_staff": 0,
             "is_active": 0, "username": "demo", "name": "demo",
             "dept_id": 2,
             "role": [2],
             },
            {"id": 2,
             "password": "pbkdf2_sha256$260000$Uv1BdUKV3O1wTbuvBWTK2s$nLbhBZ2GgCYL/jNn9Tn5QfR4Wm2mEumiTaN6obXuTuE=",
             "is_superuser": 0, "is_staff": 0,
             "is_active": 1, "username": "admin", "name": "管理员",
             "dept_id": 1,
             "role": [1],
             },
        ]
        self.save(Users, data, "用户表", no_reset=True)

    def init_sys_types(self):
        """
        初始化系统类别表
        """
        data = [
            {"id": 1, "ename": "SDGPD", "cname": "隧道供配电设施"
             },
            {"id": 2, "ename": "SDTF", "cname": "隧道通风设施"
             },
            {"id": 3, "ename": "SDZM", "cname": "隧道照明设施"
             },
            {"id": 4, "ename": "SDJK", "cname": "隧道监控与通信设施"
             },
            {"id": 5, "ename": "SDXF", "cname": "隧道消防设施"
             },
            {"id": 6, "ename": "JK", "cname": "监控设施"
             },
            {"id": 7, "ename": "SF", "cname": "收费设施"
             },
            {"id": 8, "ename": "TX", "cname": "通信设施"
             },
            {"id": 9, "ename": "GPD", "cname": "供配电设施"
             },
            {"id": 10, "ename": "ZM", "cname": "照明设施"
             },
        ]
        self.save(SysTypes, data, "系统类别表")

    def init_device_types(self):
        """
        初始化设备类别表
        """
        data = [
            {"id": 1, "ename": "SW", "cname": "交换机", "systype_id": 4
             },
            {"id": 2, "ename": "SE", "cname": "服务器", "systype_id": 4
             },
            {"id": 3, "ename": "PLC", "cname": "区域控制器", "systype_id": 4
             },
            {"id": 4, "ename": "TS", "cname": "交通信号灯", "systype_id": 4
             },
            {"id": 5, "ename": "TCMS", "cname": "洞内情报板", "systype_id": 4
             },
            {"id": 6, "ename": "CLS", "cname": "可变限速标志", "systype_id": 4
             },
            {"id": 7, "ename": "TCA", "cname": "云台摄像机", "systype_id": 4
             },
            {"id": 8, "ename": "FCA", "cname": "固定摄像机", "systype_id": 4
             },
            {"id": 9, "ename": "LS", "cname": "车道指示器(单)", "systype_id": 4
             },
            {"id": 10, "ename": "DLS", "cname": "车道指示器(双)", "systype_id": 4
             },
            {"id": 11, "ename": "TLS", "cname": "车道指示器(双-左)", "systype_id": 4
             },
            {"id": 12, "ename": "CO", "cname": "一氧化碳检测器", "systype_id": 4
             },
            {"id": 13, "ename": "VI", "cname": "能见度检测器", "systype_id": 4
             },
            {"id": 14, "ename": "TW", "cname": "风速风向检测器", "systype_id": 4
             },
            {"id": 15, "ename": "NOx", "cname": "氮氧化合物检测器", "systype_id": 4
             },
            {"id": 16, "ename": "LI", "cname": "照度检测器", "systype_id": 4
             },
            {"id": 17, "ename": "LO", "cname": "亮度检测器", "systype_id": 4
             },
            {"id": 18, "ename": "GB", "cname": "隧道广播", "systype_id": 4
             },
            {"id": 19, "ename": "DWGB", "cname": "洞外广播", "systype_id": 4
             },
            {"id": 20, "ename": "ET", "cname": "紧急电话", "systype_id": 4
             },
            {"id": 21, "ename": "DWET", "cname": "洞外紧急电话", "systype_id": 4
             },
            {"id": 22, "ename": "CH", "cname": "车通卷帘门", "systype_id": 4
             },
            {"id": 23, "ename": "RH", "cname": "人通通道门", "systype_id": 4
             },
            {"id": 24, "ename": "SBX", "cname": "设备箱", "systype_id": 4
             },
            {"id": 25, "ename": "JKSBX", "cname": "监控设备箱", "systype_id": 4
             },
            {"id": 26, "ename": "JQZM", "cname": "加强照明", "systype_id": 7
             },
            {"id": 27, "ename": "JBZM", "cname": "基本照明", "systype_id": 7
             },
            {"id": 28, "ename": "YJZM", "cname": "应急照明", "systype_id": 7
             },
            {"id": 29, "ename": "YDZM", "cname": "引道照明", "systype_id": 7
             },
            {"id": 30, "ename": "FJ", "cname": "射流风机", "systype_id": 2
             },
            {"id": 31, "ename": "AFJ", "cname": "轴流风机", "systype_id": 2
             },
            {"id": 32, "ename": "ZYFJ", "cname": "正压风机", "systype_id": 2
             },
            {"id": 33, "ename": "WP", "cname": "消防水泵", "systype_id": 5
             },
            {"id": 34, "ename": "YWY", "cname": "消防液位仪", "systype_id": 5
             },
            {"id": 35, "ename": "XHS", "cname": "消火栓", "systype_id": 5
             },
            {"id": 36, "ename": "RE", "cname": "手动火灾报警按钮", "systype_id": 5
             },
            {"id": 37, "ename": "SFD", "cname": "点型火焰探测器", "systype_id": 5
             },
            {"id": 38, "ename": "LFD", "cname": "线型火焰探测器", "systype_id": 5
             },
            {"id": 39, "ename": "IFD", "cname": "图像火焰探测器", "systype_id": 5
             },
            {"id": 40, "ename": "DFD", "cname": "双波长报警探测器", "systype_id": 5
             },
            {"id": 41, "ename": "TFD", "cname": "三波长报警探测器", "systype_id": 5
             },
            {"id": 42, "ename": "RHBZ", "cname": "人行电光标志", "systype_id": 5
             },
            {"id": 43, "ename": "CHBZ", "cname": "车行电光标志", "systype_id": 5
             },
            {"id": 44, "ename": "SSBZ", "cname": "疏散诱导标志", "systype_id": 5
             },
            {"id": 45, "ename": "TCBZ", "cname": "紧急停车带标志", "systype_id": 5
             },
            {"id": 46, "ename": "EPS", "cname": "应急电源装置", "systype_id": 1
             },
            {"id": 47, "ename": "UPS", "cname": "不间断电源", "systype_id": 1
             },
            {"id": 48, "ename": "CM", "cname": "通信管理机", "systype_id": 1
             },
            {"id": 49, "ename": "QXY", "cname": "气象检测器", "systype_id": 6
             },
            {"id": 50, "ename": "CMS", "cname": "门架式情报板", "systype_id": 6
             },
            {"id": 51, "ename": "FCMS", "cname": "悬臂式情报板", "systype_id": 4
             },
            {"id": 52, "ename": "SCMS", "cname": "立柱式情报板", "systype_id": 6
             },
            {"id": 53, "ename": "VD", "cname": "车辆检测器", "systype_id": 4
             }, {"id": 54, "ename": "TIS", "cname": "交通调查站", "systype_id": 6
                 }
        ]
        self.save(DeviceTypes, data, "设备类别表")

    def init_sys_dict(self):
        """
        初始化系统字典表
        """
        data = [
            {
                "id": "1", "name": "设备类别扩展属性命名", "value": None, "memo": "设备类型中扩展属性类别", "up_id": None
            },
            {
                "id": "2", "name": "设备类型驱动类", "value": None, "memo": "设备类型中扩展属性类别", "up_id": "1"
            },
            {
                "id": "3", "name": "设备控制命令表", "value": None, "memo": "设备类型中扩展属性类别", "up_id": "1"
            },
            {
                "id": "4", "name": "设备扩展信息类别", "value": None, "memo": "设备扩展信息类别", "up_id": None
            },
            {
                "id": "5", "name": "设备状态", "value": None, "memo": "设备扩展信息类别", "up_id": "4"
            },
            {
                "id": "6", "name": "路段等级", "value": None, "memo": "路段等级", "up_id": None
            },
            {
                "id": "7", "name": "高速公路", "value": None, "memo": "路段等级", "up_id": "6"
            },
            {
                "id": "8", "name": "一级公路", "value": None, "memo": "路段等级", "up_id": "6"
            },
            {
                "id": "9", "name": "二级公路", "value": None, "memo": "路段等级", "up_id": "6"
            },
            {
                "id": "10", "name": "三级公路", "value": None, "memo": "路段等级", "up_id": "6"
            },
            {
                "id": "11", "name": "四级公路", "value": None, "memo": "路段等级", "up_id": "6"
            },
            {
                "id": "12", "name": "构造物类别", "value": None, "memo": "构造物类别", "up_id": None
            },
            {
                "id": "13", "name": "桥梁", "value": None, "memo": "构造物类别", "up_id": "12"
            },
            {
                "id": "14", "name": "隧道", "value": None, "memo": "构造物类别", "up_id": "12"
            },
            {
                "id": "15", "name": "互通", "value": None, "memo": "构造物类别", "up_id": "12"
            },
            {
                "id": "16", "name": "收费站", "value": None, "memo": "构造物类别", "up_id": "12"
            },
            {
                "id": "17", "name": "服务区", "value": None, "memo": "构造物类别", "up_id": "12"
            },
            {
                "id": "18", "name": "道路", "value": None, "memo": "构造物类别", "up_id": "12"
            },
            {
                "id": "19", "name": "监控分中心", "value": None, "memo": "构造物类别", "up_id": "12"
            },
            {
                "id": "20", "name": "类别子名称", "value": None, "memo": "lampname", "up_id": "21"
            },
            {
                "id": "21", "name": "设备附属信息", "value": None, "memo": "设备附属信息（IP等）", "up_id": None
            },
            {
                "id": "22", "name": "设备附属信息", "value": None, "memo": "IP", "up_id": "21"
            },
            {
                "id": "23", "name": "设备附属信息", "value": None, "memo": "设备点位", "up_id": "21"
            },
            {
                "id": "24", "name": "设备附属信息", "value": None, "memo": "设备状态", "up_id": "21"
            },
            {
                "id": "25", "name": "设备状态", "value": None, "memo": "运行状态", "up_id": "24"
            },
            {
                "id": "26", "name": "设备状态", "value": None, "memo": "设备健康状态", "up_id": "24"
            },
            {
                "id": "27", "name": "设备附属信息", "value": None, "memo": "设备方向", "up_id": "21"
            },
            {
                "id": "28", "name": "设备方向", "value": None, "memo": "仁怀方向", "up_id": "27"
            },
            {
                "id": "29", "name": "设备方向", "value": None, "memo": "遵义方向", "up_id": "27"
            },
            {
                "id": "30", "name": "隧道管理所", "value": None, "memo": "构造物类别", "up_id": "12"
            },
            {
                "id": "31", "name": "养护工区", "value": None, "memo": "构造物类别", "up_id": "12"
            },
            {
                "id": "32", "name": "隧道救援站", "value": None, "memo": "构造物类别", "up_id": "12"
            },
            {
                "id": "33", "name": "停车区", "value": None, "memo": "构造物类别", "up_id": "12"
            },
            {
                "id": "34", "name": "设备品牌附属信息", "value": None, "memo": "设备品牌附属信息", "up_id": None
            },
            {
                "id": "35", "name": "设备品牌附属信息", "value": None, "memo": "驱动地址", "up_id": "34"
            },
            {
                "id": "36", "name": "设备品牌附属信息", "value": None, "memo": "PLC控制映射关系", "up_id": "34"
            },
            {
                "id": "37", "name": "设备品牌附属信息", "value": None, "memo": "PLC控制状态映射关系", "up_id": "34"
            },
            {
                "id": "38", "name": "变电所", "value": None, "memo": "隧道构件", "up_id": "14"
            },
            {
                "id": "39", "name": "水泵房", "value": None, "memo": "隧道构件", "up_id": "14"
            },
            {
                "id": "40", "name": "人行通道", "value": None, "memo": "隧道构件", "up_id": "14"
            },
            {
                "id": "41", "name": "车行通道", "value": None, "memo": "隧道构件", "up_id": "14"
            },
            {
                "id": "42", "name": "轴流风机房", "value": None, "memo": "隧道构件", "up_id": "14"
            },
            {
                "id": "43", "name": "紧急停车带", "value": None, "memo": "隧道构件", "up_id": "14"
            },
        ]

        self.save(SysDict, data, "系统字典表")

    def init_sys_menu(self):
        """
        初始化系统菜单表
        """
        data = [
            {
                "id": 1,
                "name": "综合监控",
                "sort": 1,
                "web_path": "/xxxx/xxx",
                "parent_id": None
            },
            {
                "id": 2,
                "name": "数据驾驶舱",
                "sort": 2,
                "web_path": "/xxxx/xxx",
                "parent_id": None
            },
            {
                "id": 3,
                "name": "应急指挥",
                "sort": 3,
                "web_path": "/xxxx/xxx",
                "parent_id": None
            },
            {
                "id": 4,
                "name": "平台管理",
                "sort": 4,
                "web_path": "/xxxx/xxx",
                "parent_id": None
            },
            {
                "id": 5,
                "name": "权限管理",
                "sort": 4,
                "web_path": "/xxxx/xxx",
                "parent_id": 4
            },
            {
                "id": 6,
                "name": "人员管理",
                "sort": 4,
                "web_path": "/xxxx/xxx",
                "parent_id": 4
            },
            {
                "id": 7,
                "name": "角色管理",
                "sort": 4,
                "web_path": "/xxxx/xxx",
                "parent_id": 4
            }
        ]
        self.save(Menu, data, "系统菜单表")

    def init_sys_road(self):
        """
        初始化路线信息
        """
        data = [
            {
                "id": 1,
                "ename": "RZGS",
                "cname": "仁遵高速",
                "roadwidth": 22.5,
                "roadweight": 3,
                "roadlength": 52.4512,
                "hademergency": True,
                "roadtraffic": True,
                "lstartplno": "K3+000",
                "lendplno": "K57+200",
                "direct": None,
                "roadcode": "G4215仁遵段",
                "lane": None,
                "rstartplno": None,
                "rendplno": None,
                "pointname1": "遵义",
                "pointname2": "仁怀",
                "geoservice": "http://192.168.0.106/geoserver/gz/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=gz%3Arenzun&outputFormat=application%2Fjson",
                "creator": None,
                "roadtype_id": 1,
                "upid": None,
                "manunit": None
            },
            {
                "id": 2,
                "ename": "RCGS",
                "cname": "仁赤高速",
                "roadwidth": None,
                "roadweight": None,
                "roadlength": 190.225,
                "hademergency": True,
                "roadtraffic": True,
                "lstartplno": "K379+200",
                "lendplno": "K452+310",
                "direct": None,
                "roadcode": "G4215仁赤段",
                "lane": None,
                "rstartplno": None,
                "rendplno": None,
                "pointname1": "赤水",
                "pointname2": "仁怀",
                "geoservice": None,
                "creator": None,
                "roadtype_id": 1,
                "upid": None,
                "manunit": None
            },
            {
                "id": 3,
                "ename": "SZGS",
                "cname": "思遵高速",
                "roadwidth": None,
                "roadweight": None,
                "roadlength": 123.839,
                "hademergency": True,
                "roadtraffic": True,
                "lstartplno": "K1508+000",
                "lendplno": "K1622+000",
                "direct": None,
                "roadcode": "G56思遵段",
                "lane": None,
                "rstartplno": None,
                "rendplno": None,
                "pointname1": "遵义",
                "pointname2": "思南",
                "geoservice": None,
                "creator": None,
                "roadtype_id": 1,
                "upid": None,
                "manunit": None
            },
            {
                "id": 4,
                "ename": "DWGS",
                "cname": "德务高速",
                "roadwidth": None,
                "roadweight": None,
                "roadlength": 40.694,
                "hademergency": True,
                "roadtraffic": True,
                "lstartplno": "K0+000",
                "lendplno": "K40+587",
                "direct": None,
                "roadcode": "S10德务段",
                "lane": None,
                "rstartplno": None,
                "rendplno": None,
                "pointname1": "务川",
                "pointname2": "德江",
                "geoservice": None,
                "creator": None,
                "roadtype_id": 1,
                "upid": None,
                "manunit": None
            },
            {
                "id": 5,
                "ename": "WZGS",
                "cname": "务正高速",
                "roadwidth": None,
                "roadweight": 3,
                "roadlength": 47.9,
                "hademergency": True,
                "roadtraffic": True,
                "lstartplno": "K18+385",
                "lendplno": "K61+600",
                "direct": None,
                "roadcode": "S10务正段",
                "lane": None,
                "rstartplno": None,
                "rendplno": None,
                "pointname1": "正安",
                "pointname2": "务川",
                "geoservice": None,
                "creator": None,
                "roadtype_id": 1,
                "upid": None,
                "manunit": None
            }
        ]
        self.save(RoadsInfos, data, "路线信息表")

    def init_sys_structures(self):
        """
        初始化构造物信息
        """
        data = [
            {
                "id": 1,
                "structtype": 14,
                "sname": "小窝凼隧道",
                "lstartplno": "ZK5+408",
                "lendplno": "ZK6+049",
                "centerplno": None,
                "rstartplno": "YK5+405",
                "rendplno": "YK6+057",
                "upid": None,
                "lat": 106.444189883569,
                "lon": 27.8837016737321,
                "creator": None,
                "roadid_id": 1,
                "manunit": None
            }
            ,
            {
                "id": 2,
                "structtype": 14,
                "sname": "奶子山隧道",
                "lstartplno": "ZK9+015",
                "lendplno": "ZK9+652",
                "centerplno": None,
                "rstartplno": "YK9+010",
                "rendplno": "YK9+648",
                "upid": None,
                "lat": 106.475579680387,
                "lon": 27.8650587117276,
                "creator": None,
                "roadid_id": 1,
                "manunit": None
            },
            {
                "id": 3,
                "structtype": 14,
                "sname": "石笋沟隧道",
                "lstartplno": "ZK10+081",
                "lendplno": "ZK15+445",
                "centerplno": None,
                "rstartplno": "YK10+071",
                "rendplno": "YK15+410",
                "upid": None,
                "lat": 106.503422282286,
                "lon": 27.8537442596652,
                "creator": None,
                "roadid_id": 1,
                "manunit": None
            },
            {
                "id": 4,
                "structtype": 14,
                "sname": "琵琶树隧道",
                "lstartplno": "ZK15+546",
                "lendplno": "ZK16+743",
                "centerplno": None,
                "rstartplno": "YK15+501",
                "rendplno": "YK16+703",
                "upid": None,
                "lat": 106.53003067118,
                "lon": 27.8321341097898,
                "creator": None,
                "roadid_id": 1,
                "manunit": None
            },
            {
                "id": 5,
                "structtype": 14,
                "sname": "灵宝山隧道",
                "lstartplno": "ZK17+506",
                "lendplno": "ZK18+935",
                "centerplno": None,
                "rstartplno": "YK17+493",
                "rendplno": "YK18+910",
                "upid": None,
                "lat": 106.541921646842,
                "lon": 27.8186656942477,
                "creator": None,
                "roadid_id": 1,
                "manunit": None
            },
            {
                "id": 6,
                "structtype": 14,
                "sname": "大发渠1号隧道",
                "lstartplno": "ZK21+837",
                "lendplno": "ZK22+645",
                "centerplno": None,
                "rstartplno": "YK21+812",
                "rendplno": "YK22+642",
                "upid": None,
                "lat": 106.564875954519,
                "lon": 27.7980483512236,
                "creator": None,
                "roadid_id": 1,
                "manunit": None
            },
            {
                "id": 7,
                "structtype": 14,
                "sname": "大发渠2号隧道",
                "lstartplno": "ZK22+885",
                "lendplno": "ZK23+138",
                "centerplno": None,
                "rstartplno": "YK22+855",
                "rendplno": "YK23+135",
                "upid": None,
                "lat": 106.56667161156,
                "lon": 27.7976350606921,
                "creator": None,
                "roadid_id": 1,
                "manunit": None
            },
            {
                "id": 8,
                "structtype": 14,
                "sname": "莲花山隧道",
                "lstartplno": "ZK24+030",
                "lendplno": "ZK24+745",
                "centerplno": None,
                "rstartplno": "YK24+025",
                "rendplno": "YK24+722",
                "upid": None,
                "lat": 106.57171130997,
                "lon": 27.7964060690826,
                "creator": None,
                "roadid_id": 1,
                "manunit": None
            },
            {
                "id": 9,
                "structtype": 14,
                "sname": "凤凰山隧道",
                "lstartplno": "ZK26+907",
                "lendplno": "ZK30+425",
                "centerplno": None,
                "rstartplno": "YK26+885",
                "rendplno": "YK30+410",
                "upid": None,
                "lat": 106.630432837338,
                "lon": 27.7861068154665,
                "creator": None,
                "roadid_id": 1,
                "manunit": None
            },
            {
                "id": 10,
                "structtype": 14,
                "sname": "大屋基隧道",
                "lstartplno": "ZK32+375",
                "lendplno": "ZK36+273",
                "centerplno": None,
                "rstartplno": "YK32+392",
                "rendplno": "YK36+309",
                "upid": None,
                "lat": 106.6915323991,
                "lon": 27.771708458974,
                "creator": None,
                "roadid_id": 1,
                "manunit": None
            }
        ]
        self.save(Structures, data, "构造物表")

    def run(self):
        self.init_dept()
        # self.init_button()
        # self.init_menu()
        # self.init_menu_button()
        self.init_role()
        self.init_users()
        self.init_sys_types()
        self.init_device_types()
        self.init_sys_dict()
        self.init_sys_menu()
        self.init_sys_road()
        self.init_sys_structures()


# 项目init 初始化，默认会执行 main 方法进行初始化
def main(reset=False):
    Initialize(reset).run()
    pass


if __name__ == '__main__':
    main()
